package com.dayaokeji.rhythmschoolstudent.client.home.course.task;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayaokeji.rhythmschoolstudent.R;
import com.dayaokeji.rhythmschoolstudent.utils.DateUtils;
import com.dayaokeji.server_api.domain.CourseTask;

/**
 * Created by Gorden on 2018/3/22.
 */

public class CourseTaskAdapter extends BaseQuickAdapter<CourseTask,BaseViewHolder> {

    public CourseTaskAdapter() {
        super(R.layout.item_course_task, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, CourseTask item) {
        helper.setText(R.id.tv_task_content,item.getContent());
        final TextView tvDesc = helper.getView(R.id.tv_desc);
        if (TextUtils.isEmpty(item.getDescribe())) {
            tvDesc.setVisibility(View.GONE);
        }
        tvDesc.setText(item.getDescribe());
        helper.setText(R.id.tv_desc, item.getDescribe());
        try {
            long finishTime = Long.parseLong(item.getFinishTime());
            String finishFormat = DateUtils.format(finishTime, DateUtils.FORMAT_DATE);
            helper.setText(R.id.tv_finish_time,"截止时间："+finishFormat);
        }catch (Exception e) {

        }
    }
}
